package com.itheima.Test;

import java.util.Random;
import java.util.Scanner;

public class LoopTest05 {
    public static void main(String[] args) {
        Random rand = new Random();
        int number = rand.nextInt(100) + 1;
        System.out.println(number);
        int count = 0;
        while(true) {
            count++;
            if(count == 3) {
                System.out.println("猜中了");
                break;
            }
            System.out.println("输入一个数字");
            Scanner sc = new Scanner(System.in);
            int guessNumber = sc.nextInt();
            if(guessNumber < number) {
                System.out.println("小了");
            } else if(guessNumber > number) {
                System.out.println("大了");
            } else {
                System.out.println("猜中了");
                break;
            }

        }
    }
}
